package l1j.opqlo;

import l1j.opqlo.Server.L1World.L1World;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_ChatPacket;

public class SuperNGChat implements Runnable {

	private final L1PcInstance _pc;
	private final S_ChatPacket _packet;
	private int _time;
	private final int _oid;
	private static String msg = "買、賣、交換請使用交易頻道，違者禁言處分。";
	private static final int S_OPCODE_NORMALCHAT = 35;// 一般聊天頻道

	public SuperNGChat(L1PcInstance pc, int time) {
		this._pc = pc;
		this._packet = new S_ChatPacket(pc, msg, S_OPCODE_NORMALCHAT, 0);
		this._time = time;
		this._oid = pc.getId();
	}

	@Override
	public void run() {
		while (this._time > 0) {
			try {
				Thread.sleep(1000);
			} catch (final InterruptedException e) {
			}
			if (L1World.getInstance().findObject(this._oid) == null) {
				break;
			}
			this._pc.sendPackets(this._packet);
			this._time--;
		}
	}
}
